{% extends "layout.html" %}
{% macro PutInLabel(LblType,Txt,id)  -%}
    {% if LblType=="Question" %}
        <a href="/Task/Question/{{ id }}"><button class="btn btn-xs btn-warning">{{ Txt }}</button></a>
    {% elif LblType=="Error" %}
        <a href="/Task/Show/{{ id }}"><button class="btn btn-xs btn-danger">{{ Txt }}</button></a>
    {% elif LblType=="Running" %}
        <a href="/Task/Show/{{ id }}"><button class="btn btn-xs btn-info">{{ Txt }}</button></a>
    {% elif LblType=="Done" %}
        <a href="/Task/Show/{{ id }}"><button class="btn btn-xs btn-success">{{ Txt }}</button></a>
    {% else %}
        {{ Txt }}
    {% endif %}
{%- endmacro %}

{% block body %}
  <a class='btn btn-default'  href=?cleandone=Y{{ seeall }}>Clean All Done</a>
  <a class='btn btn-default' href=?cleanerror=Y{{ seeall }}>Clean All Error</a>
  <a class='btn btn-default' href=?cleanall=Y{{ seeall }}>Clean All (warning !!!)</a>  Task count : {{  len_tasks }}
  <a class='btn btn-default' href=?seeall=Y>See All users tasks </a>
<table class="table">
    <tr><th>ID</th><th>Task type</th><th>Owner</th>
    <th>State</th><th>Step</th><th width="60px">%</th><th>Message</th><th>Creation date</th><th>Last update</th></tr>
 {% for t in tasks %}

    <tr><td><a href="/Task/Show/{{ t.id }}"> {{ t.id }} <button class="btn btn-xs btn-primary">View</button></a></td>
    <td>{{ t.taskclass }}</td>
    <td>{{ t.owner_rel.name }}</td>
    <td>{{ PutInLabel(t.taskstate,t.taskstate,t.id) }}</td><td>{{ t.taskstep }}</td>
        <td>{{ t.progresspct }} %</td>
        <td>{{ t.progressmsg }}</td>
        <td>{{ t.creationdate|datetime }}</td>
        <td>{{ t.lastupdate|datetime }}</td>

  {% endfor %}
</table>

{% endblock %}